import pagesjson from "@/pages.json";
// import { reactive } from "vue";  

export function usePages() {
	// const style = reactive({});  
	function getCurrentPage() {
		const pages = getCurrentPages();
		// 某些特殊情况下(比如页面进行redirectTo时的一些时机)，pages可能为空数组  
		return `${pages[pages.length - 1]?.route ?? ""}`;
	}

	function getCurrentStyle() {
		const route = getCurrentPage();

		const getCurrentStyle = pagesjson.pages.find((item) => item.path == route);

		return getCurrentStyle.style ?? undefined;
	}

	function getCurrentTitle() {
		const style = getCurrentStyle();
		return style ? style.navigationBarTitleText : "";
	}

	return {
		getCurrentPage,
		getCurrentStyle,
		getCurrentTitle,
	};
}